package org.example.statistics.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import org.example.statistics.domain.StatisticsMonthMoney;
import org.example.statistics.service.IStatisticsMonthMoneyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 统计月份报Controller
 *
 * @author 小孟微信：xiaomengcode
 * @date 2024-05-18
 */
@Controller
@RequestMapping("/statistics/statisticsMonthMoney")
public class StatisticsMonthMoneyController extends BaseController
{
    private String prefix = "statistics/statisticsMonthMoney";

    @Autowired
    private IStatisticsMonthMoneyService statisticsMonthMoneyService;

    @GetMapping()
    public String statisticsMonthMoney()
    {
        return prefix + "/statisticsMonthMoney";
    }

    /**
     * 查询统计月份报列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StatisticsMonthMoney statisticsMonthMoney)
    {
        startPage();
        List<StatisticsMonthMoney> list = statisticsMonthMoneyService.selectStatisticsMonthMoneyList(statisticsMonthMoney);
        return getDataTable(list);
    }

    /**
     * 导出统计月份报列表
     */
    @RequiresPermissions("statistics:statisticsMonthMoney:export")
    @Log(title = "统计月份报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StatisticsMonthMoney statisticsMonthMoney)
    {
        List<StatisticsMonthMoney> list = statisticsMonthMoneyService.selectStatisticsMonthMoneyList(statisticsMonthMoney);
        ExcelUtil<StatisticsMonthMoney> util = new ExcelUtil<StatisticsMonthMoney>(StatisticsMonthMoney.class);
        return util.exportExcel(list, "统计月份报数据");
    }

    /**
     * 新增统计月份报
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存统计月份报
     */
    @RequiresPermissions("statistics:statisticsMonthMoney:add")
    @Log(title = "统计月份报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StatisticsMonthMoney statisticsMonthMoney)
    {
        return toAjax(statisticsMonthMoneyService.insertStatisticsMonthMoney(statisticsMonthMoney));
    }

    /**
     * 修改统计月份报
     */
    @RequiresPermissions("statistics:statisticsMonthMoney:edit")
    @GetMapping("/edit/{statisticsId}")
    public String edit(@PathVariable("statisticsId") Long statisticsId, ModelMap mmap)
    {
        StatisticsMonthMoney statisticsMonthMoney = statisticsMonthMoneyService.selectStatisticsMonthMoneyByStatisticsId(statisticsId);
        mmap.put("statisticsMonthMoney", statisticsMonthMoney);
        return prefix + "/edit";
    }

    /**
     * 修改保存统计月份报
     */
    @RequiresPermissions("statistics:statisticsMonthMoney:edit")
    @Log(title = "统计月份报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StatisticsMonthMoney statisticsMonthMoney)
    {
        return toAjax(statisticsMonthMoneyService.updateStatisticsMonthMoney(statisticsMonthMoney));
    }

    /**
     * 删除统计月份报
     */
    @RequiresPermissions("statistics:statisticsMonthMoney:remove")
    @Log(title = "统计月份报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(statisticsMonthMoneyService.deleteStatisticsMonthMoneyByStatisticsIds(ids));
    }


}
